﻿using System;

namespace FunctionalCLR.Core.Functions.Maths {

    /// <summary>
    /// Get the sign of the parameter.
    /// 
    /// echo(sign(-2));
    /// -1
    /// </summary>
    public class SignNode : FuncNode {
        public SignNode()
            : base() {
            base.Value = "sign";
            this.ParameterCount = 1;
        }

        public override object Evaluate() {
            double result = Convert.ToDouble(
                Children[0].Evaluate());

            return Math.Sign(result).ToString();
        }
    }
}
